﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Infrastructure;
using Enterprise.Model.Manager;
using Enterprise.Service.Manager;
using Enterprise.Service.User;
namespace Enterprise.UI.Web.Modules.Manager
{
    public partial class ReplyMsg : Enterprise.Service.BasePage
    {
        int Id = (int)Utility.sink("Id", Utility.MethodType.Get, 0, 0, Utility.DataType.Int);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnStart();
            }
        }

        /// <summary>
        /// 设置基础数据
        /// </summary>
        private void OnStart()
        {
            MsgService mService = new MsgService();
            var query = mService.MsgDisp(Id);
            if (query != null)
            {
                MsgTitle.Text = query.MsgTitle;
                MsgContent.Text = query.MsgContent;
                MsgIsshow.Text = query.MsgIsShow == 0 ? "不公开" : "公开";
                UserTxt.Text = query.msgIsAnonymous == 1 ? "匿名" : UserService.GetUserName(query.MsgFUser);
                MsgTime.Text = query.MsgCreateTime.ToString();
            }
        }

        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_OnClick(object sender, EventArgs e)
        {
            string _note = "操作成功";
            MsgReplyEntity entity = new MsgReplyEntity();
            entity.MsgId = Id;
            entity.ReplyContent = (string)Utility.sink(ReplyContent.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
            entity.ReplyIsShow = (int)Utility.sink(ReplyIsShow.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Int);
            entity.ReplyIp = Utility.GetIPAddress();
            entity.ReplyTime = DateTime.Now;
            entity.DB_Option_Action = "Insert";
            MsgReplyService mrService = new MsgReplyService();
            mrService.MsgReplyExecute(entity);
            Utility.ShowMsg(this.Page, "OK", this.Tran(_note), "Index.aspx");
        }

    }
}